# ----------------------------------------------------------------------- #
# Description : DAP     makefile                                          #
# Author      : dikim at Gnewsoft.                                        #
# Create      : 02/23/11                                                  #
# This code is cap                                                        #
# ----------------------------------------------------------------------- #
.SUFFIXES = .c.o

PROC_NAME = psim

CC=gcc

INCDIR	= -I${HOME}/inc
LIBDIR 	= -L${HOME}/lib -L/opt/fota/lib

CFLAGS  = -g -O3 -Wall -D_REENTRANT -D_4WAY -D_SLEEP ${G_PROJ_DEFINE} 
LFLAGS  = -lpthread -lnsl -lgolog -lgoutil -lgotimer -lgocomm -lgoipc -lgoenv
SRCS	= main.c mq.c work.c util.c

OBJECT_PREFIX=${HOME}/.objs
OBJECT_PATH=${OBJECT_PREFIX}/func/cap/psim
OBJECT_PATH2=${OBJECT_PREFIX}/func/cap
OBJS=${SRCS:%.c=${OBJECT_PATH}/%.o}
OBJS2=${OBJECT_PATH2}/parser.o

#EXS		= ${OBJECT_PATH}/${PROC_NAME}
EXS		= ${PROC_NAME}

ALL: dir ${EXS}

$(EXS): $(OBJS)
	$(CC) -o $@ $(OBJS) $(OBJS2) ${LIBDIR} $(CFLAGS) $(LFLAGS)

install: ${EXS}
	if [ -f "/opt/${USER}/bin/${PROC_NAME}" ] ; then mv /opt/${USER}/bin/${PROC_NAME} /opt/${USER}/bin/${PROC_NAME}_old; fi
	cp -p ${EXS} /opt/${USER}/bin

$(OBJECT_PATH)/%.o: %.c
	${CC} -c -o $@ $(INCDIR) ${CFLAGS}  $<

clean:
	rm -f ${OBJS} core ${EXS}

dir:
	if [ ! -f ${OBJECT_PATH} ] ; then mkdir -p ${OBJECT_PATH}; fi
